﻿using System;
using nRoute.Components.Composition;
using nRoute.Utilities;

namespace nRoute.Mapping
{
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
    public class DefineNavigationContentAttribute
		 : MapNavigationContentAttribute
    {
        private readonly Type _contentType;

        public DefineNavigationContentAttribute(string url, Type contentType)
		 : base(url)
        {
            Guard.ArgumentNotNull(contentType, "contentType");
            _contentType = contentType;
        }

        public Type ContentType
        {
            get { return _contentType; }
        }

#region overrides 

        protected internal override IResourceLocator GetResourceLocator(Type targetType, ITypeBuilder typeBuilder)
        {
            // we switch the target type with our given content type
            return base.GetResourceLocator(_contentType, typeBuilder);
        }

#endregion

    }
}